<?php
class OrderModel extends RelationModel {
	protected $tableName = 'order_info';
	
	protected $_link = array(
			'member'=>array(
					'mapping_type'=>BELONGS_TO,
					'class_name'=>'member',
					'foreign_key'=>'user_id',
					'mapping_fields' => 'user_id,user_name, true_name, email, mobile, address'
			),
			'goods_info' => array(
					'mapping_type'=>HAS_MANY,
					//'class_name'=>'Member',
					'foreign_key'=>'order_id',
					'mapping_fields' => 'goods_id, goods_src, goods_name, goods_color, goods_size, price_cny, num, num_check',
			),
	);
	
	public $status_arr = array(
			'0' => '未处理',
			'1' => '已确认',
			'2' => '收到货款',
			'3' => '成功订购',
			'4' => '已发货',
			'5' => '已完成',
			'9' => '无效订单',
	);
	
	public $status_arr_9 = array(
			'0' => '未处理',
	);
	
	public function get_status_arr(){
		return $this->status_arr;
	}
	
	public function get_next_status_arr($cur_status){
		$str = '';
		switch ($cur_status){
			case '0':
				$str = '1,2,3,4,5';
				break;
			case '1':
				$str = '2,3,4,5,9';
				break;
			case '2':
				$str = '3,4,5';
				break;
			case '3':
				$str = '4,5';
				break;
			case '4':
				$str = '5';
				break;
			case '5':
				break;
			case '9':
				$str = '0';
				break;
			default:
				break;
		}
		
		$status_arr = array();
		if($str != ''){
			$arr = explode(',', $str);
			foreach($arr as $k)
				$status_arr[$k] = $this->status_arr[$k];
		}
		
		return $status_arr;
	}
	
}

?>